#-*-coding:utf-8-*-
import hou
class Miscellaneous(object):
    def __init__(self):
        super(Miscellaneous,self).__init__()

    def setAnonymousUsageStatistics_SendAnonymousUsageStatistics(self,bool):
        if bool == True:
            hou.setPreference('misc.cansendanonymousstats.val','1')
            # print('1')
        else:
            hou.setPreference('misc.cansendanonymousstats.val','0')
            # print('0')

    def getAnonymousUsageStatistics_SendAnonymousUsageStatistics(self):
        return hou.getPreference('misc.cansendanonymousstats.val')
        # print('getAnonymousUsageStatistics_SendAnonymousUsageStatistics')


    def setWebBrowser_RestrictWebBrowserToSafeCommands(self,bool):
        if bool == True:
            hou.setPreference('misc.restricttosafe.val','1')
            # print('1')
        else:
            hou.getPreference('misc.restricttosafe.val','0')
            # print('0')

    def getWebBrowser_RestrictWebBrowserToSafeCommands(self):
        return hou.getPreference('misc.restricttosafe.val')
        # print('getWebBrowser_RestrictWebBrowserToSafeCommands')


    def setWebBrowser_UseExternalHelpServer(self,bool):
        if bool == True:
            hou.setPreference('misc.useexternalhelp.val','1')
            # print('1')
        else:
            hou.setPreference('misc.useexternalhelp.val','0')
            # print('0')

    def getWebBrowser_UseExternalHelpServer(self):
        return hou.getPreference('misc.useexternalhelp.val')
        # print('getWebBrowser_UseExternalHelpServer')



    def setWebBrowser_UseExternalHelpServer_ExternalHelpURL(self,url):
        hou.setPreference('misc.externalhelpurl.val', url)
        # print('setWebBrowser_UseExternalHelpServer_ExternalHelpURL')

    def getWebBrowser_UseExternalHelpServer_ExternalHelpURL(self):
        return hou.getPreference('misc.externalhelpurl.val')
        # print('getWebBrowser_UseExternalHelpServer_ExternalHelpURL')


    def setUndo_Reserve(self,value):
        hou.setPreference('general.undolimit.val',str(value))
        # print('setUndo_Reserve')

    def getUndo_Reserve(self):
        return hou.getPreference('general.undolimit.val')
        # print('getUndo_Reserve')

    def setRevertToDefaults_DeleteChannelsWhenRevertingToDefaults(self,bool):
        if bool == True:
            hou.setPreference('misc.destructive_revert.val','1')
            # print('1')
        else:
            hou.setPreference('misc.destructive_revert.val','0')
            # print('0')

    def getRevertToDefaults_DeleteChannelsWhenRevertingToDefaults(self):
        return hou.getPreference('misc.destructive_revert.val')
        # print('getRevertToDefaults_DeleteChannelsWhenRevertingToDefaults')



    def setRevertToDefaults_RevertInvisibleParametersToDefault(self,bool):
        if bool == True:
            hou.setPreference('misc.revert_invisible.val','1')
            # print('1')
        else:
            hou.setPreference('misc.revert_invisible.val','0')
            # print('0')

    def getRevertToDefaults_RevertInvisibleParametersToDefault(self):
        return hou.getPreference('misc.revert_invisible.val')
        # print('getRevertToDefaults_RevertInvisibleParametersToDefault')



    def setChannelLoading_MakeSpareParametersForUnknownChannels(self,bool):

        if bool == True:
            hou.setPreference('misc.make_spare_parms.val', '1')
            # print('1')
        else:
            hou.setPreference('misc.make_spare_parms.val', '0')
            # print('0')

    def getChannelLoading_MakeSpareParametersForUnknownChannels(self):
        return hou.getPreference('misc.make_spare_parms.val')
        # print('getChannelLoading_MakeSpareParametersForUnknownChannels')



    def setSpareHDAParameterDeletion(self,deletionNum):
        '''
        :param deletionNum: 0 - Automatically Delete all References,
        1 - Automatically Delete only Simple Channel References
        2 - Do Not Automatically Delete any References
        :return:
        '''
        hou.setPreference('misc.parmdel_warnings.val', str(deletionNum))
        # print('setSpareHDAParameterDeletion')

    def getSpareHDAParameterDeletion(self):
        return hou.getPreference('misc.parmdel_warnings.val')
        # print('getSpareHDAParameterDeletion')



    def setOpenCL_Device_Type(self,typeNum):
        '''
        :param typeNum: 0 - GPU , 1 - CPU
        :return:
        '''
        hou.setPreference('misc.opencl_devicetype.menu',str(typeNum))
        # print('setOpenCL_Device_Type')


    def getOpenCL_Device_Type(self):
        return hou.getPreference('misc.opencl_devicetype.menu')
        # print('getOpenCL_Device_Type')



    def setDevice(self,deviceNum):
        '''

        :param deviceNum: 根据你的设备来的
        :return:
        '''
        hou.setPreference('misc.opencl_device.menu', str(deviceNum))
        # print('setDevice')

    def getDevice(self):
        return hou.getPreference('misc.opencl_device.menu')
        # print('getDevice')